package com.sci.web.dao;

import java.util.List;

import com.jfinal.plugin.activerecord.Page;
import com.sci.web.model.genmodel.SysEnums;

public class SysEnumsDao extends SysEnums {
	
	
	public static final SysEnumsDao me = new SysEnumsDao();
	
	
	
	public int insertSysEnums(SysEnums sysEnums){
		boolean save = sysEnums.save();
		return save==true?1:0;
	}
	
	
	public int updateSysEnums(SysEnums sysEnums){
		boolean update = sysEnums.update();
		return update==true?1:0;
	}

	
	public Page<SysEnums> geetSysEnumsPageInate(int pageNumber , int pageSize){
		
		String selectStr = " select *  ";
		String whereStr = " from "+SysEnums.tableName+"  where 1=1 order by update_time desc ";
		return dao.paginate(pageNumber, pageSize, selectStr, whereStr);
	}
	
	
	public SysEnums geetSysEnumsById(String id){
		return dao.findById(id);
	}
	
	
	
	
	public List<SysEnums> geetSysEnumsByMainKey(String mainKey){
		String sql = " select * from  "+ SysEnums.tableName + " where main_key = ? ";
		return dao.find(sql , mainKey);
	}
	
	
	
	public List<SysEnums> geetSysEnumsAll(){
		String sql = " select * from  "+ SysEnums.tableName + " where is_delete='0'" ;
		return dao.find(sql);
	}
	
	
	
	
	
	
	public SysEnums geetSysEnumsByKey(String mainKey , String eKey){
		List<SysEnums> geetSysEnumsByMainKey = this.geetSysEnumsByMainKey(mainKey);
		if(geetSysEnumsByMainKey!=null){
			for (SysEnums sysEnums : geetSysEnumsByMainKey) {
				if(eKey.equals(sysEnums.getEKey())){
					return sysEnums;
				}
			}
		}
		return null;
	}
	
	
}
